#ifndef _Scene_H_
#define _Scene_H_
#include <QtOpenGL/qgl.h>
#include <math.h>

#include "model.h"
#include "maze.h"
#include "character.h"
#include "bullet.h"

const int kNumBullets = 20;

class Scene
{
private:

  // Dades de l'escena
  int time_;
  int maze_size_;
  Maze *maze_;
  int character_rotation_;
  Model *player_model_;
  Model *enemy_model_;
  Character *player_;
  int enemy_count_;
  std::vector<Character*> enemies_;
  std::vector<Bullet*> bullets_;
  int bullet_count_;
  bool destruction_enabled_;

  void RemovePlayer();
  void RemoveEnemies();
  void RemoveBullet(int);
  void RemoveBullets();
  void ResetPlayer();
  void ResetEnemies();

public:
  static MaterialLib matlib;	  // col·lecció de materials

  Scene();
  ~Scene();
  void Reset();
  void GenerateMaze(int size);
  void Click(int, int);
  Point GetCenter();
  float GetRadius();
  void LoadPlayerModel(QString file);
  void MovePlayer(Movement);
  bool IsPlayerAlive();
  Point GetPlayerPosition();
  Direction GetPlayerOrientation();
  void SetEnemyCount(int);
  void LoadEnemyModel(QString file);
  void RemoveEnemy(int);
  void Update();
  bool IsReady();
  void Render(bool render_player, int player_rotation);
  void PickRender();
  void EnemyPickRender();
  void Shoot();
  void SwitchDestruction();
};

inline bool pcmp(int ax, int az, int bx, int bz) {
  return ax == bx && az == bz;
}

#endif

